<?php
require_once("userView.php");
require_once(CORE_DIR.'userModel.php');
require_once(CORE_DIR.'taskpointModel.php');

class getusersAction extends authAction{

	function __construct(){
		$this->view = new userView();
	}

	public function run($get, $post, $viewtype) {
		parent::run($get,$post,$viewtype);
		
		$uModel = new userModel();
		$pointModel = new taskpointModel();
		
		if (isset($get["mode"]) && $get["mode"] == "full"){
			$users = $uModel->getFullUsersList();
			$this->view->setProperty("users", $users);
			$this->view->showFullUsersList();
		}
		else if(isset($get["userid"])){
			$userid = $get["userid"];
			$user = $uModel->getUsersData($userid);
			$user["points"] = $pointModel->getUserPointsById($userid);
			
			$this->view->setProperty("users", array($user));
			$this->view->showFullUsersList();
		}
		else {
			$users = $uModel->getUsersList();
			$this->view->setProperty("users", $users);
			$this->view->showUsersList();
		}
	}
}
?>